/* *  
 * Copyright (C) 2004-2008 Mocha Almond Fudge AI, SIT KMUTT
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package jboard.util;

import org.apache.log4j.FileAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

/**
 * Logger using Log4J
 * 
 * @author -NOP-
 */
public class MyLogger {
	// Log4J
	static Logger logger = Logger.getLogger(Logger.class);
	private FileAppender appender;
	private ModifyLog4JLayout layout;
	
	public MyLogger() {
		layout = new ModifyLog4JLayout();
		appender = null;
		try {
			appender = new FileAppender(layout, "debug.txt", true); // Append file
		} catch(Exception e) {}
		logger.addAppender(appender);
		logger.setLevel((Level) Level.DEBUG);
	}
	
	public MyLogger(String fileName) {
		layout = new ModifyLog4JLayout();
		appender = null;
		try {
			appender = new FileAppender(layout, fileName, true); // Append file
		} catch(Exception e) {}
		logger.addAppender(appender);
		logger.setLevel((Level) Level.DEBUG);
	}
	
	public void debug(String message) {
		logger.debug(message);
	}
}
